<!-- src/components/ai/RecommendSpotsList.vue -->
<template>
    <div class="recommend-container">
        <!-- 景点列表 -->
        <div class="spots-list custom-scrollbar">
            <el-empty v-if="!spots.length" description="暂无推荐景点" />
            <div v-else class="spot-cards">
                <el-card v-for="spot in spots" class="spot-card" shadow="hover" @click="handleSpotClick(spot)">
                    <template #header>
                        <div class="card-header">
                            <h3>{{ spot.name }}</h3>
                        </div>
                    </template>
                    <div class="card-content">
                        <p class="description">{{ spot.suggestion }}</p>
                    </div>
                </el-card>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
interface Spot {
    name: string;
    suggestion: string;
}

defineProps<{
    spots: Spot[];
}>()

const emit = defineEmits(['spot-click'])

const handleSpotClick = (spot: Spot) => {
    emit('spot-click', spot.name)
}
</script>

<style scoped>
.recommend-container {
    height: 100%;
    background-color: #f5f7fa;
}

.overall-suggestion {
    padding: 16px;
    background: #f5f7fa;
    border-radius: 8px;
    margin: 16px;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.spots-list {
    height: calc(100vh - 120px);
    /* 固定高度，留出头部空间 */
    overflow-y: auto;
    padding: 16px;
}


.spot-cards {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    cursor: pointer;
}

.spot-card {
    border-radius: 8px;
    transition: all 0.3s ease;
    background: white;
    position: relative;
    /* 添加这行，让伪元素相对于卡片定位 */
}

.spot-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-header {
    padding: 8px 12px;
    border-bottom: 1px solid #ebeef5;
    background-color: #f8fafc;
    border-radius: 8px 8px 0 0;
}

.card-header h3 {
    margin: 0;
    font-size: 15px;
    color: #303133;
    font-weight: 600;
}

.card-content {
    padding: 12px;
    background: linear-gradient(to bottom, #ffffff, #f9fafc);
}

.description {
    margin: 0;
    color: #606266;
    font-size: 13px;
    line-height: 1.5;
}

/* 添加卡片装饰效果 */
.spot-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: #74b8fc;
    border-radius: 8px 0 0 8px;
    opacity: 0.6;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #c0c4cc;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f5f7fa;
}
</style>